const Mock = require('mockjs')

const data = Mock.mock({
  'items|30': [{
    id: '@id',
    title: '@sentence(10, 20)',
    'status|1': ['published', 'draft', 'deleted'],
    author: 'name',
    display_time: '@datetime',
    pageviews: '@integer(300, 5000)'
  }]
})

const data1 = Mock.mock({
  'items': function () {
    const arr = []
    for (let i = 0; i < 6; i++) {
      const num = Mock.mock({
        'number|1-100': 100
      })
      arr.push(num.number)
    }
    return arr
  }
})

module.exports = [
  {
    url: '/mock/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/mock/echarts1',
    type: 'get',
    response: config => {
      const items = data1.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }
]
